package com.hh.materialCostPrice.controller;/*
 * @Auther:ZhengXueCheng
 * @Date:2023/8/3
 * @VERSON:1.8
 */

import com.hh.legalFactory.service.LegalFactoryService;
import com.hh.materialCostPrice.Vo.AddSparePriceVo;
import com.hh.materialCostPrice.Vo.ModifySparePriceVo;
import com.hh.materialCostPrice.Vo.QueryPageVo;
import com.hh.materialCostPrice.Vo.UpdateStatusVo;
import com.hh.materialCostPrice.service.CostPriceService;
import com.hh.spare.vo.SpareVo;
import com.hh.utils.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;

@RestController
@RequestMapping("/materialCostPrice")
@CrossOrigin
public class materialCostPriceController {

    @Autowired
    private CostPriceService costPriceService;

    @Autowired
    private LegalFactoryService legalFactoryService;

    /**
     * 分页查询
     * @param queryPageVo
     * @return
     */
    @PostMapping("queryPage")
    private ResultVo queryMaterialCostPrice(@RequestBody QueryPageVo queryPageVo){
        return costPriceService.queryMaterialCostPrice(queryPageVo);
    }

    /**
     * 备件成本状态修改
     * @param statusVo
     * @return
     */
    @PostMapping("updateStatus")
    private ResultVo updateSparePriceStatus(@RequestBody UpdateStatusVo statusVo){
        return costPriceService.updateSparePriceStatus(statusVo);
    }

    @PostMapping("update")
    private ResultVo updateSparePrice(@RequestBody ModifySparePriceVo modifyVo){
        return costPriceService.updateSparePrice(modifyVo);
    }

    @PostMapping("add")
    private ResultVo addSparePrice(@RequestBody AddSparePriceVo addSparePriceVo) throws ParseException {
        return costPriceService.addSparePrice(addSparePriceVo);
    }


    /**
     * 根据法人code查询法人工厂
     * @param legalPersonCode
     * @return
     */
    @GetMapping("/queryPlantListByLegalPersonCode")
    public ResultVo queryPlantListByLegalPersonCode(@RequestParam("legalPersonCode") String legalPersonCode) {
            return legalFactoryService.getPlanByLegalCode(legalPersonCode);
    }

    /**
     * 查询税码类型
     * @return
     */
    @GetMapping("/queryAllTaxType")
    public ResultVo queryAllTaxType() {
        return costPriceService.queryAllTaxType();
    }

    /**
     * 查询备件
     * @param spareVo
     * @return
     */
    @PostMapping("/querySparePage")
    public ResultVo querySparePage(@RequestBody SpareVo spareVo) {
        return costPriceService.querySparePage(spareVo);
    }


}
